global !p

from mdtex.scopes import text
import datetime

def get_week(date_str):
    now_time        = datetime.datetime.strptime(date_str, "%Y-%m-%d")
    week_start_time = now_time - datetime.timedelta(days = now_time.weekday())
    week_end_time   = week_start_time + datetime.timedelta(days = 4)
    return [datetime.datetime.date(week_start_time), datetime.datetime.date(week_end_time)]

endglobal

################################################################
#                                                              #
#                           Template                           #
#                                                              #
################################################################

context "snip.line == 0 and snip.column == 3"
snippet temp "模板 Temp" b
`!p
ifweek  = "Week" in snip.basename
snip.rv = "## " + (("第 " + str(int(snip.basename[5:7])) + " 周") if ifweek else snip.basename)
`

- ${1:`!p
if ifweek:
    week    = get_week('20' + snip.basename[8:16])
    snip.rv = str(week[0]) + " ~ " + str(week[1])
else:
    snip.rv = snip.basename
`}
- 编写时间：${2:`!p snip.rv = snip.basename[11:16] if ifweek else snip.basename[5:]`}

[toc]

### 任务

$3

### 笔记

$0
endsnippet

context "snip.line == 0 and snip.column == 0"
snippet p "判断正误 True or False (For Vanki)" b
判断正误：


endsnippet
